package com.itcast.activiti.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itcast.activiti.entity.ApproveRemoveSign;
import com.itcast.activiti.mapper.ApproveRemoveSignMapper;
import com.itcast.activiti.service.IApproveRemoveSignService;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author itcast
 * @since 2021-12-21
 */
@Service
public class ApproveRemoveSignServiceImpl extends ServiceImpl<ApproveRemoveSignMapper, ApproveRemoveSign> implements IApproveRemoveSignService {

    @Override
    public void add(String removeSignId, String taskDefinitionKey, String processDefinitionId, String newProcessDefinitionId, String assignee) {
        ApproveRemoveSign approveRemoveSign = new ApproveRemoveSign();
        approveRemoveSign.setId(removeSignId);
        approveRemoveSign.setTaskDefinitionKey(taskDefinitionKey);
        approveRemoveSign.setProcDefIdOld(processDefinitionId);
        approveRemoveSign.setProcDefId(newProcessDefinitionId);
        approveRemoveSign.setState(Boolean.TRUE);
        approveRemoveSign.setCreatedBy(assignee);
        approveRemoveSign.setCreatedDatetime(LocalDateTime.now());
        baseMapper.insert(approveRemoveSign);
    }

    @Override
    public List<ApproveRemoveSign> findByProcDefIdOlds(List<String> processDefinitionIds) {
        return baseMapper.selectList(Wrappers.<ApproveRemoveSign>lambdaQuery().in(ApproveRemoveSign::getProcDefIdOld, processDefinitionIds));
    }
}
